package com.three.controller;

import com.three.domain.Departments;
import com.three.service.DepartmentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class DepartmentsController {
    @Autowired
    private DepartmentsService departmentsService;

    @RequestMapping(value = "/List")
    public Object departmentsList() {
        return departmentsService.List();
    }
    @RequestMapping(value = "/departmentsList")
    public Object departmentsList(@RequestBody Map<String, Object> map) {
        Integer pageIndex = (Integer) map.get("pageIndex");
        Integer pageSize = (Integer) map.get("pageSize");
        String keyword = (String) map.get("keyword");
        return departmentsService.departmentsList(pageIndex, pageSize, keyword);
    }

    @RequestMapping(value = "/addDepartments")
    public Object addDepartments(@RequestBody Departments departments) {
        return departmentsService.addDepartments(departments);
    }

    @RequestMapping(value = "/updateDepartments")
    public Object updateDepartments(@RequestBody Departments departments) {
        return departmentsService.updateDepartments(departments);
    }

    @RequestMapping(value = "/deleteDepartments")
    public Object deleteDepartments(@RequestBody Departments departments) {
        return departmentsService.deleteDepartments(departments.getDepartment_id());
    }
}
